<template>
    <div id="son-of-son">
        <span>爷爷组件给孙子直接用provide传值</span>
        <div><input type="text" v-model="num"></div>
        <a-button @click="$emit('toInjectSon', 'I am from sunzi')" type="primary">给injectSon传值</a-button>
    </div>
</template>
<script lang="ts">
import {inject} from 'vue'
export default {
    name: 'sunzizujian',
    // emits:['toInjectSon'],
    setup(){
        // inject可以直接接收从爷爷组件传过来的值 prop2是index组件传值的
        const num:any = inject('prop2')
        return{
            num
        }
    },
}
</script>